﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Text;
using System.Windows.Forms;

namespace MikeProject002
{
    public class Linq2Sql
    {
        public static void F_001_get_data()
        {
            MyClasses.NorthwindDataContext dc = new MyClasses.NorthwindDataContext();

            var query = from p in dc.Products where p.ProductName.StartsWith("M") select new { p.ProductID, p.ProductName };

            Table<MyClasses.Product> query2 = dc.Products;

            var query3 = dc.Ten_Most_Expensive_Products();
            

            foreach (var Item in query3)
            {
                MessageBox.Show(string.Format("Item.ProductID = {0}, Item.ProductName = {1}", Item.TenMostExpensiveProducts , Item.UnitPrice));
                
            }


        }

        public static void F_002_set_data_Room_reserv(MyClasses.RoomReservation rs)
        {
            using (MyClasses.MikeDbDataContext Data = new MyClasses.MikeDbDataContext())
            {

                Data.RoomReservations.InsertOnSubmit(rs);
                Data.SubmitChanges();
            }

        }

        public static MyClasses.RoomReservation[] F_003_GetRums()
        {
            using (MyClasses.MikeDbDataContext Data = new MyClasses.MikeDbDataContext())
            {
                return (from p in Data.RoomReservations select p).ToArray();


            }


        }
    }
}
